﻿
GO



if not exists(select * from VitCode_Castle_User where code='admin')
INSERT INTO [VitCode_Castle_User]
           ([Id]
           ,[Code]
           ,[Password]
           ,[Name]
           ,[Number]
           ,[Email]
           ,[Mobile]
           ,[IsInUsed]
           ,[UserGroupId]
           ,[Memo])
     VALUES
           (newid()
           ,'admin'
           ,'rpzWciUE+Wk='
           ,'admin'
           ,'001'
           ,''
           ,''
           ,1
           ,null
           ,null)
go
if not exists (select * from VitCode_Castle_Menu where Name='系统设置')
begin
declare @Id uniqueidentifier
declare @adminId uniqueidentifier
select @adminId = Id from VitCode_Castle_user where code='admin'
set @Id=newid()
INSERT INTO [VitCode_Castle_Menu]
           ([Id],[Name] ,[UrlPath],[Memo],[ParentId],[OrderId],[SortKey] ,[Operate])
     VALUES(@Id,'系统设置','ZZ' ,null,null,convert(varchar(50),@Id),'Z00','Add;Edit;Delete')
end
go


if not exists (select * from VitCode_Castle_Menu where Name='后台设置')
begin
declare @Id uniqueidentifier
declare @ParentId uniqueidentifier
select @ParentId = Id from VitCode_Castle_Menu where Name='系统设置'
declare @adminId uniqueidentifier
select @adminId = Id from VitCode_Castle_user where code='admin'
set @Id=newid()
INSERT INTO [VitCode_Castle_Menu]
           ([Id],[Name],[UrlPath],[Memo],[ParentId],[OrderId],[SortKey]
           ,[Operate])
     VALUES
           (@Id ,'后台设置','../BackStageManagement/Main.aspx',null,@ParentId,Convert(varchar(50),@ParentId)+'.'+convert(varchar(50),@Id)
           ,'Z01','Add;Edit;Delete')
end
go
if not exists (select * from VitCode_Castle_Menu where Name='批量处理')
begin
declare @Id uniqueidentifier
declare @adminId uniqueidentifier
select @adminId = Id from VitCode_Castle_user where code='admin'
set @Id=newid()
INSERT INTO [VitCode_Castle_Menu]
           ([Id],[Name] ,[UrlPath],[Memo],[ParentId],[OrderId],[SortKey]
           ,[Operate])
     VALUES(@Id,'批量处理','PP' ,null,null,convert(varchar(50),@Id),'P00','Add;Edit;Delete')
end
go


if not exists (select * from VitCode_Castle_Menu where Name='批量导入')
begin
declare @Id uniqueidentifier
declare @ParentId uniqueidentifier
select @ParentId = Id from VitCode_Castle_Menu where Name='批量处理'
declare @adminId uniqueidentifier
select @adminId = Id from VitCode_Castle_user where code='admin'
set @Id=newid()
INSERT INTO [VitCode_Castle_Menu]
           ([Id],[Name],[UrlPath],[Memo],[ParentId],[OrderId],[SortKey]
           ,[Operate])
     VALUES
           (@Id ,'批量导入','../BaseData/DataImportor.aspx',null,@ParentId,Convert(varchar(50),@ParentId)+'.'+convert(varchar(50),@Id)
           ,'P01','Add;Edit;Delete')
end
go
if not exists (select * from VitCode_Castle_Menu where Name='业务功能')
begin
declare @Id uniqueidentifier
declare @adminId uniqueidentifier
select @adminId = Id from VitCode_Castle_user where code='admin'
set @Id=newid()
INSERT INTO [VitCode_Castle_Menu]
           ([Id]
           ,[Name]
           ,[UrlPath]
           ,[Memo]
           ,[ParentId]
           ,[OrderId]
           ,[SortKey]
           ,[Operate])
     VALUES
           (@Id
           ,'业务功能'
           ,'B'
           ,null
           ,null
           ,Convert(varchar(50),@Id)
           ,'B00'
           ,'Add;Edit;Delete'
			)
end
go
if not exists(select * from VitCode_Castle_role where alias='SysAdmin')
begin
declare @Id uniqueidentifier
declare @adminId uniqueidentifier
select @adminId = Id from VitCode_Castle_user where code='admin'
set @Id=newid()
INSERT INTO [VitCode_Castle_Role]
           ([Id]
           ,[Alias]
           ,[Name]
           ,[Memo])
     VALUES
           (@Id
           ,'SysAdmin'
           ,'系统管理员'
           ,null)
end

insert into dbo.VitCode_Castle_UserRoleRelation (Id,UserId,RoleId)
values(newid(),@adminId,@Id)

go

